<template>
  <div class="product-item">
    <img :src="product.imgUrl" :alt="product.title" class="product-img">
    <div class="product-title">{{ product.title }}</div>
    <div class="product-price">¥{{ product.price.toFixed(2) }}</div>
    <div class="product-tag" v-if="product.tag">{{ product.tag }}</div>
    <div class="product-actions">
      <el-button type="danger" size="small">加入购物车</el-button>
    </div>
  </div>
</template>

<script setup>
defineProps({
  product: {
    type: Object,
    required: true
  }
})
</script>

<style lang="scss" scoped>
.product-item {
  position: relative;
  border: 1px solid transparent;
  padding: 10px;
  transition: all 0.3s;
  
  &:hover {
    border-color: #e1251b;
    box-shadow: 0 0 10px rgba(0,0,0,0.1);
    transform: translateY(-3px);
    
    .product-actions {
      opacity: 1;
    }
  }
  
  .product-img {
    width: 100%;
    height: 200px;
    object-fit: contain;
  }
  
  .product-title {
    font-size: 14px;
    margin: 10px 0;
    height: 40px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }
  
  .product-price {
    font-size: 18px;
    color: var(--primary-color);
    font-weight: bold;
  }
  
  .product-tag {
    position: absolute;
    top: 10px;
    right: 10px;
    background-color: var(--primary-color);
    color: white;
    padding: 2px 5px;
    font-size: 12px;
    border-radius: 2px;
  }
  
  .product-actions {
    margin-top: 10px;
    opacity: 0;
    transition: opacity 0.3s;
    text-align: center;
  }
}
</style> 